package com.zhilianbao.leyaogo.utils;

import android.content.Context;
import android.os.Environment;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.GlideModule;
import com.zhilianbao.leyaogo.constants.CacheConfig;

/**
 * ClassName: GlideDiakCacheModule <br>
 * Description: 自定义Glide磁盘缓存<br>
 * Author: Cyarie <br>
 * Created: 2016/9/26 13:47 <br>
 * Update Time：<br>
 * Update Description：<br>
 */
public class GlideDikCacheModule implements GlideModule {

    private String downloadDirectoryPath = Environment.getExternalStorageDirectory() + CacheConfig.GLIDE_IMAGE_CACHE_NAME;

    @Override
    public void registerComponents(Context context, Glide glide) {

    }

    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        builder.setDiskCache(
                new DiskLruCacheFactory(downloadDirectoryPath, CacheConfig.DISK_MAX_CACHE_SIZE)
        );
    }
}
